<?

	CO_authority( );

	$JO[ "guide"		] = JO( array( "EN" => "Guide"	, "KO" => "안내"	, "VI" => "Guide"	) );
	$JO[ "record"		] = JO( array( "EN" => "Record"	, "KO" => "기록"	, "VI" => "Record"	) );

	$JO[ "period"		] = JO( array( "EN" => "Period"	, "KO" => "기간"	, "VI" => "Period"	) );
	$JO[ "type"			] = JO( array( "EN" => "Type"	, "KO" => "분류"	, "VI" => "Type"	) );
	$JO[ "amount"		] = JO( array( "EN" => "Amount"	, "KO" => "금액"	, "VI" => "Amount"	) );
	$JO[ "file"			] = JO( array( "EN" => "File"	, "KO" => "파일"	, "VI" => "File"	) );

	$CO[ "collection"	] = JO( array( "EN" => "Collection"	, "KO" => "정산 중"		, "VI" => "Collection"	) );
	$CO[ "settlement"	] = JO( array( "EN" => "Settlement"	, "KO" => "정산 완료"	, "VI" => "Settlement"	) );
	$CO[ "payment"		] = JO( array( "EN" => "Payment"	, "KO" => "지불 완료"	, "VI" => "Payment"		) );

?>



<div class="JO_bar_720">

	<h1><?= $JO[ "settlement" ] ?> <?= $JO[ "guide" ] ?></h1>

	<div>

		<? if(	$_SESSION[ "JO_account_language"	] == "EN"				||
				$_SESSION[ "JO_account_authority"	] == "administrator"	||
				$_SESSION[ "JO_account_authority"	] == "observer"			||
				$_SESSION[ "JO_account_authority"	] == "SO"				) { ?>

			

		<? } ?>

		<? if(	$_SESSION[ "JO_account_language"	] == "KO"				||
				$_SESSION[ "JO_account_authority"	] == "administrator"	||
				$_SESSION[ "JO_account_authority"	] == "observer"			||
				$_SESSION[ "JO_account_authority"	] == "SO"				) { ?>

			각 콘텐트 별 유통 기록은 '<a href="?CO_unit=14_content" class="JO_positive">콘텐트</a>' 메뉴에서 확인하실 수 있습니다.<br />

			콘텐트 유통자 시스템 사정으로 일부 콘텐트 유통 기록과 실제 최종 정산 결과 사이에 다소 오차가 있을 수 있습니다.

		<? } ?>

		<? if(	$_SESSION[ "JO_account_language"	] == "VI"				||
				$_SESSION[ "JO_account_authority"	] == "administrator"	||
				$_SESSION[ "JO_account_authority"	] == "observer"			||
				$_SESSION[ "JO_account_authority"	] == "SO"				) { ?>

		<? } ?>

		<hr />

	</div>


</div>



<div class="JO_bar_720">

	<h1><?= $JO[ "settlement" ] ?> <?= $JO[ "record" ] ?></h1>

	<div>

		<table>

			<tr>
				<th style="width: 145px;"	><?= $JO[ "period"	] ?></th>
				<th style="width: 65px;"	><?= $JO[ "type"	] ?></th>
				<th style="width: 105px;"	><?= $JO[ "amount"	] ?></th>
				<th							><?= $JO[ "file"	] ?></th>
			</tr>

			<?

				$query = "
					SELECT	`type`,
							`amount`,
							`from`,
							`to`,
							`file`
					FROM	`settlement`
					WHERE	`delete` IS NULL
				";

				if(	$_SESSION[ "JO_account_authority" ] != "administrator"	&&
					$_SESSION[ "JO_account_authority" ] != "observer"		&&
					$_SESSION[ "JO_account_authority" ] != "SO"				) $query .= " 
						AND	`organization` = '" . $_SESSION[ "JO_account_organization" ] . "'
					";

					$recordSet = JO_query( $query );

					if( $recordSet -> num_rows ) while( $record = $recordSet -> fetch_array( ) ) {

			?>

				<tr>

					<td><?= JO_date( $record[ "from" ] ) ?> <span class="JO_gray_40">~</span> <?= JO_date( $record[ "to" ] ) ?></td>

					<td><?= $CO[ $record[ "type" ] ] ?></a></td>

					<td class="JO_right"><?= number_format( $record[ "amount" ] ) ?> <span class="JO_gray_40">VND</span></td>

					<td>

						<? if( $record[ "file" ] ) foreach( JO_string_textArray( $record[ "file" ], $assign = ":", $separate = "\r\n" ) as $key => $value ) { ?>

							<a href="JO_72_CO/CO_82_file_settlement/<?= $value ?>"><?= $key ?></a>

						<? } ?>

					</td>

				</tr>

			<? } else { ?>

				<tr>

					<td colspan="4" class="JO_center">...</td>

				</tr>

			<? } ?>

		</table>


	</div>

</div>
